package com.airy.highSpeed.controller;

/**
 * @Author: Ding Ya Kun.
 * @Description:
 * @Date:Created in 2020.12.25 11:04
 */

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.airy.highSpeed.entity.RktxEntity;
import com.airy.highSpeed.entity.StaLaneHeartBeatEntity;
import com.airy.highSpeed.service.RktxService;
import com.airy.highSpeed.service.StaLaneHeartBeatService;
import com.airy.highSpeed.service.StationparentService;
import com.airy.highSpeed.utils.PageUtils;
import com.airy.highSpeed.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * ${comments}
 *
 * @author dingyakun
 * @email 821041490@qq.com
 * @date 2020-12-15 13:21:16
 */
@RestController
@RequestMapping("product/slhb")
public class StaLaneHeartBeatController {

    @Autowired
    private StaLaneHeartBeatService staLaneHeartBeatService;

    /**
     * 查询所有
     */
    @RequestMapping("/findAll")
    public R findAll(){
        List<StaLaneHeartBeatEntity> staLaneHeartBeatEntityList = staLaneHeartBeatService.findAll();

        return R.ok().put("长度",staLaneHeartBeatEntityList.size());
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = staLaneHeartBeatService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
        StaLaneHeartBeatEntity staLaneHeartBeatEntity = staLaneHeartBeatService.getById(id);

        return R.ok().put("staLaneHeartBeatEntity", staLaneHeartBeatEntity);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody StaLaneHeartBeatEntity staLaneHeartBeat){
        staLaneHeartBeatService.save(staLaneHeartBeat);


        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody StaLaneHeartBeatEntity staLaneHeartBeat){
        staLaneHeartBeatService.updateById(staLaneHeartBeat);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody String[] ids){
        staLaneHeartBeatService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    public List<StaLaneHeartBeatEntity> findByTollStationId(String tollStationId) {
        return staLaneHeartBeatService.findByTollStationId(tollStationId);
    }
}

